<?php

/*
 * Created on 2008-12-14
 *
 * To change the template for this generated file go to
 * Window - Preferences - PHPeclipse - PHP - Code Templates 
 */
?>
<html> 
<head> 
	<title>Results</title> 
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<link rel="stylesheet" type="text/css" href="css/resultats.css" /> 	
	<style> 
		body {
			overflow : hidden;
		}
		a {
			display : block;
			padding : 6px;
			text-decoration : none;
			background-image : url(images/fond_a.gif);
			background-repeat : no-repeat;
			color : black;
		}
		a:hover {
			background-image : url(images/fond_a_over.gif);
		}
	</style> 
</head> 
<body scroll="no"> 
<div id="waiter"> 
	<OBJECT width=359 
	        height=178 
	        classid="clsid:D27CDB6E-AE6D-11CF-96B8-444553540000"
	        codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=4,0,2,0"> 
	        <param name=movie value="images/004.swf"> 
	        <param name=quality value=high> 
	  <EMBED src="images/004.swf"
	         width=359 
	         height=178 
	         quality=high 
	         pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash"
	         type="application/x-shockwave-flash"> 
	  </EMBED> 
	</OBJECT> 
</div> 
<script language="javascript" type="text/javascript"> 
	function hide_loader() {
		progress();
		document.getElementById("waiter").style.display = "none";
	}
	function progress() {
		if(result1) {
			if(!result1 || !result2) return false
			
			if(i <= result1) histo1.style.height = i+"px";
			if(i <= result2) histo2.style.height = i+"px";
			i++;
			if(i<=100) {
				setTimeout("progress()", 2);
			} else {
				a = document.getElementsByTagName("SPAN")
				for(j=0; j<a.length; j++) { 
					a[j].style.display = "inline";
				}
				histo1.style.padding="3px"; 
				histo2.style.padding="3px"; 
				if(parseInt(histo1.style.height) < 22) histo1.style.height = "22px";
				if(parseInt(histo2.style.height) < 22) histo2.style.height = "22px";
				if(winner) winner.style.color = "#82D7E3";
			}
		}
	}
	setTimeout('hide_loader()', 5000);
 </script>
 <?php

include ("class/function.php");
$word1 = strip_tags($_GET['word1']);
$word2 = strip_tags($_GET['word2']);
$url1 = "/search?hl=zh-CN&num=1&q=" . urlencode($word1);
$url2 = "/search?hl=zh-CN&num=1&q=" . urlencode($word2);
$res1 = match_google($url1);
$res2 = match_google($url2);
if ($res1 == null || $res1 == "") {
	$res1 = "0";
	$num1 = 0;
} else {
	$num1 = str_replace(',', '', $res1);
}
if ($res2 == null || $res2 == "") {
	$res2 = "0";
	$num2 = 0;
} else {
	$num2 = str_replace(',', '', $res2);
}
?>
<table cellspacing="0"> 
	<caption> 
		Results on Google :  
	 </caption> 
	<tr> 
		<td valign="bottom" id="result1" class="resultat"> 
			<b><?php echo $word1;?></b> 
			<div id="histo1" class="histo"> 
				<span><?php echo $res1;?> results</span> 
			 </div> 
		 </td> 
		<td valign="bottom" id="result2" class="resultat"> 
			<b><?php echo $word2;?></b><br /> 
			<div id="histo2" class="histo"> 
				<span><?php echo $res2;?> results</span> 
			</div> 
		 </td> 
	 </tr> 
 </table> 
<script language="javascript" type="text/javascript"> 
	<?php ?>
	var result1 = '<?php echo (int)(($num1/($num1 + $num2))*150); ?>';
	var result2 = '<?php echo (int)(($num2/($num1 + $num2))*150); ?>';
	var histo1 = document.getElementById('histo1');
	var histo2 = document.getElementById('histo2');
	var winner = 'result<?php echo ($num1>$num2) ? 1 : 2 ;?>';
	if(winner!="") var winner = document.getElementById(winner);
	var i = 0;
 </script> 
</body> 
</html>